<script setup lang="ts">
import { useToastStore } from '@/stores/toast'
import Toast from './Toast.vue'

const toastStore = useToastStore()
</script>

<template>
  <div class="toast-container">
    <Toast
      v-for="toast in toastStore.toasts"
      :key="toast.id"
      :message="toast.message"
      :type="toast.type"
      @close="toastStore.removeToast(toast.id)"
    />
  </div>
</template>

<style scoped>
.toast-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
}

.toast-container :deep(.toast) {
  pointer-events: auto;
  margin-top: 1rem;
}

/* 添加堆叠效果 */
.toast-container :deep(.toast:not(:first-child)) {
  margin-top: -0.5rem;
  z-index: calc(1000 - var(--i, 0));
}
</style> 